|
RAIS
3.2
|
00001 00028 using System; 00029 using System.Data; 00030 using System.Configuration; 00031 using System.Collections; 00032 using System.Web; 00033 using System.Web.Security; 00034 using System.Web.UI; 00035 using System.Web.UI.WebControls; 00036 using System.Web.UI.WebControls.WebParts; 00037 using System.Web.UI.HtmlControls; 00038 00039 using Cultures = System.Collections.Generic.Dictionary<string, RAIS.Common.Localization.Culture>; 00040 using RAIS.Common.UserManagement; 00041 //using RAIS.ApplicationLogicLayer; 00042 00043 namespace RAIS.UI.SpecificMasks 00044 { 00048 public partial class RegionalSettings : System.Web.UI.Page 00049 { 00050 //********************************************************************* 00051 #region Properties 00052 00055 protected UserData CurrentUser 00056 { 00057 get { return (UserData)this.Session[UI.Common.Constants.CURRENT_USER_TAG]; } 00058 } 00059 #endregion 00060 #region Event handlers 00061 protected void Page_PreLoad(object sender, EventArgs e) 00062 { 00063 RAIS.UI.Common.PageManagement.TrimTextBoxValues(this); 00064 } 00071 protected void Page_Load(object sender, EventArgs e) 00072 { 00073 this.Response.Cache.SetNoStore(); 00074 if (this.CurrentUser == null) 00075 UI.Common.AccessManagement.SignOut(this); 00076 00077 this.EnableDisableButtons(); 00078 this.LBLresult.Text = string.Empty; 00079 00080 if (!this.IsPostBack) 00081 { 00082 UI.Common.Localisation.InitializeCulturesList(this.DDLcultures); 00083 UI.Common.Localisation.InitializeLanguagesSelection(this.LBlanguage.Items); 00084 this.LBLusernameNoTranslation.Text = this.CurrentUser.Name; 00085 00086 this.BTNdelete.Attributes.Add("onclick", string.Format("javascript: return confirm('{0}');", RAIS.Common.Messages.DELETE_QUESTION_CULTURE)); 00087 UI.Common.PageManagement.InitializePage(this, this.TreeView1); 00088 } 00089 UI.Common.PageManagement.InitHelpMainMenu(LBTNdefault); 00090 this.LBLadmin.ForeColor = RAIS.UI.Common.Constants.COLOR_OF_MENU_BAR_TEXT_HIGHLIGHT; 00091 // this.LBTNmessagebox.Visible = !(this.CurrentUser.FunctionalRole.Type == FunctionRole.FunctionRoleType.Guest); 00092 } 00093 protected void Page_Init(object sender, EventArgs e) 00094 { 00095 Common.PageManagement.SetScrolableListBox(LBlanguage, this, true); 00096 } 00103 protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) 00104 { 00105 UI.Common.UserManagement.ProcessTreeViewOnRedirect(this.TreeView1); 00106 } 00107 00114 protected void LBTNlogout_Click(object sender, EventArgs e) 00115 { 00116 UI.Common.AccessManagement.SignOut(this); 00117 } 00124 protected void BTNnewLanguage_Click(object sender, EventArgs e) 00125 { 00126 this.AddNewLanguage(); 00127 } 00134 protected void LBlanguage_SelectedIndexChanged(object sender, EventArgs e) 00135 { 00136 this.EnableDisableButtons(); 00137 this.SetRightToLeftStatus(); 00138 } 00145 protected void CBrightToLeft_CheckedChanged(object sender, EventArgs e) 00146 { 00147 RAIS.Common.Localization.Culture culture = this.SelectedCulture; 00148 culture.RightToLeft = this.CBrightToLeft.Checked; 00149 00150 string validationMessage = ""; 00151 ApplicationLogicLayer.Localisation.SaveCulture(culture, ref validationMessage); 00152 } 00159 protected void BTNdelete_Click(object sender, EventArgs e) 00160 { 00161 RAIS.Common.Localization.Culture culture = this.SelectedCulture; 00162 if (this.ConfirmCultureDeletion()) 00163 { 00164 string validationMessage = ""; 00165 bool success = ApplicationLogicLayer.Localisation.DeleteCulture(culture, ref validationMessage); 00166 00167 UI.Common.Localisation.InitializeLanguagesSelection(this.LBlanguage.Items); 00168 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage( this.LBLresult, 00169 validationMessage, 00170 success); 00171 } 00172 } 00179 protected void BTNedit_Click(object sender, EventArgs e) 00180 { 00181 this.Session[RAIS.UI.Common.Constants.SELECTED_TARGET_CULTURE] = this.SelectedCulture; 00182 this.Response.Redirect(RAIS.UI.Common.Constants.EDIT_TRANSLATION_PAGE); 00183 } 00190 protected void BTNeditHelp_Click(object sender, EventArgs e) 00191 { 00192 this.Session[RAIS.UI.Common.Constants.SELECTED_TARGET_CULTURE] = this.SelectedCulture; 00193 this.Response.Redirect(RAIS.UI.Common.Constants.EDIT_HELP_PAGE); 00194 } 00195 00196 #endregion 00197 #region Private helper methods 00198 00202 private bool AddNewLanguage() 00203 { 00204 string validationMessage = ""; 00205 bool success = false; 00206 if (this.DDLcultures.SelectedItem != null) 00207 { 00208 int selectedLCID = Int32.Parse(this.DDLcultures.SelectedItem.Value); 00209 00210 RAIS.Common.Localization.Culture newCulture = new RAIS.Common.Localization.Culture(selectedLCID); 00211 00212 success = ApplicationLogicLayer.Localisation.AddCulture(newCulture, ref validationMessage); 00213 if (success) 00214 { 00215 UI.Common.Localisation.InitializeLanguagesSelection(this.LBlanguage.Items); 00216 00217 } 00218 RAIS.UI.Common.MessageDisplay.DisplayReturnMessage( this.LBLresult, 00219 validationMessage, 00220 success); 00221 } 00222 return success; 00223 } 00227 private void EnableDisableButtons() 00228 { 00229 bool enable = this.LBlanguage.Items.Count > 0 && this.Cultures.ContainsKey(this.LBlanguage.SelectedValue); 00230 if (enable) 00231 { 00232 Cultures supportedLanguages = RAIS.ApplicationLogicLayer.Localisation.SupportedLanguages; 00233 this.BTNeditHelp.Enabled = enable; 00234 enable = this.SelectedCulture.LCID != supportedLanguages[RAIS.Common.Constants.DEFAULT_LANGUAGE].LCID; 00235 00236 this.BTNdelete.Enabled = enable; 00237 this.BTNedit.Enabled = enable; 00238 this.CBrightToLeft.Enabled = enable; 00239 } 00240 else 00241 { 00242 this.BTNdelete.Enabled = false; 00243 this.BTNedit.Enabled = false; 00244 this.CBrightToLeft.Enabled = false; 00245 this.BTNeditHelp.Enabled = false; 00246 } 00247 } 00251 private void SetRightToLeftStatus() 00252 { 00253 if (this.SelectedCulture != null) 00254 this.CBrightToLeft.Checked = this.SelectedCulture.RightToLeft; 00255 } 00261 private Cultures Cultures 00262 { 00263 get 00264 { 00265 return RAIS.ApplicationLogicLayer.Localisation.SupportedLanguages; 00266 } 00267 } 00273 private RAIS.Common.Localization.Culture SelectedCulture 00274 { 00275 get 00276 { 00277 Cultures cultures = this.Cultures; 00278 if (this.LBlanguage.Items.Count > 0 && cultures.ContainsKey(this.LBlanguage.SelectedValue)) 00279 return cultures[this.LBlanguage.SelectedValue]; 00280 else 00281 return null; 00282 } 00283 } 00288 private bool ConfirmCultureDeletion() 00289 { 00290 return true; 00291 } 00292 #endregion 00293 00294 } 00295 }